/**
 * Copyright (c) 2010 Jesco Freund.
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without modification,
 * are permitted provided that the following conditions are met:
 *
 * 1. Redistributions of source code must retain the above copyright notice,
 *    this list of conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * 3. Neither the name of Backtory nor the names of its contributors may be used
 *    to endorse or promote products derived from this software without
 *    specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 *
 *  $Id$
 */


#ifndef __LIBYAR_THREADING_H
#define __LIBYAR_THREADING_H

#include <libyar/types.h>

#define YAR_THREADING_LOCK    0x01
#define YAR_THREADING_UNLOCK  0x02

extern void YAR_THREADING_threadid_set_callback(void (*threadid_func)(yar_threadid_t *id));
extern void YAR_THREADING_threadid_set_numeric(yar_threadid_t *id, uint64_t val);
extern void YAR_THREADING_threadid_set_pointer(yar_threadid_t *id, void *ptr);
extern int  YAR_THREADING_locking_num_locks(void);
extern void YAR_THREADING_locking_set_callback(void (*func)(int mode, int n, const char *file, int line));
extern void YAR_THREADING_locking_set_mode(int mode, int n, const char *file, int line);

#define YAR_THREADING_lock(n)   YAR_THREADING_locking_set_mode(YAR_THREADING_LOCK, (n), __FILE__, __LINE__)
#define YAR_THREADING_unlock(n) YAR_THREADING_locking_set_mode(YAR_THREADING_UNLOCK, (n), __FILE__, __LINE__)

#endif /* __LIBYAR_THREADING_H */
